<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.entity.Goods" %>
<%@ page import="com.entity.Catalogue" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="com.dao.GoodsCtrl" %>
<%@ page import="com.dao.CatalogCtrl"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>库存管理</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
		<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/modal.js" type="text/javascript" charset="utf-8"></script>
</head>

<script type="text/javascript"> 
/* function SelectedAll(cb) { 
	cb.checked = cb.checked ? false : true; 
	var gv = document.getElementById("BuCodeSearch"); 
	var rc = gv.rows.length; 
	for (var i = 1; i < rc; i++) { 
	var input = gv.rows[i].cells[0].getElementsByTagName("input"); 
	if (input[0].type == "checkbox" && input[0].checked) { 
	input[0].checked = false; 
	gv.rows[i].style.backgroundColor = ""; 
	} 
	else { 
	input[0].checked = true; 
	gv.rows[i].style.backgroundColor = "#D4D4D4;"; 
	} 
	} 
	} 

function SelectedSingle(cb) { 
	var row = cb.parentNode.parentNode; 
	if (cb.checked) { 
	row.style.backgroundColor = "#D4D4D4;"; 
	} 
	else { 
	row.style.backgroundColor = ""; 
	} 
	}  */
	function unselectall(){
		if(document.myform.chkAll.checked){
		document.myform.chkAll.checked = document.myform.chkAll.checked&0;
		}
		}
	function CheckAll(form){
		for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.Name != 'chkAll'&&e.disabled==false)
		e.checked = form.chkAll.checked;
		}
		}
	function CheckSingle(){
		//location.href = "http://www.baidu.com";
	    var r=document.getElementsByName("id");  
	    var chestr="";
	    for(var i=0;i<r.length;i++){
	         if(r[i].checked){
	        chestr+=r[i].value; 
	         }
	    }
	    if(chestr == "")
	    {
	       alert("请先选择！");
	       //var s = "Add";
	    }
	    else
	    { 	  
	    	   	alert("您先择的是："+chestr);
	    }  
	}
</script> 

<body>
<div id="header">
			<div class="col w5 bottomlast">
				<a href="" class="logo">
					<img src="images/logo.gif" alt="Logo" />
				</a>
			</div>
			<div class="col w5 last right bottomlast">
				<p class="last"> 用户名<span class="strong">Admin,</span> <a href="">注销</a></p>
			</div>
			<div class="clear"></div>
		</div>
		<div id="wrapper">
			<div id="minwidth">
				<div id="holder">
					<div id="menu">
						<div id="left"></div>
						<div id="right"></div>
						<ul>
							<li>
								<a href="index.jsp" class="selected"><span>库存管理</span></a>
							</li>
							<li>
								<a href="newGood.jsp" ><span>新建库存</span></a>
							</li>
							<li>
								<a href="checkOrder.jsp"><span>查看领用单</span></a>
							</li>
						</ul>
						<div class="clear"></div>
					</div>
					<div id="submenu">
						<div class="modules_left">
						<div class="col w1">
							<div class="content">
								<label for="select">Select:</label>
						    </div>
						</div>
								
							<div class="col w1">
								<div class="content">
									<form action="test.php">
										<p>
											<select name="select" id="select">
											<%
											CatalogCtrl cc= new CatalogCtrl();
											ArrayList<Catalogue> catalogList = cc.getCatalog();
											if(catalogList==null)
											{
												catalogList=new ArrayList<Catalogue>();
											}
											int num = catalogList.size();
											for(int i =0; i<num; i++){
												int catalog_id = catalogList.get(i).getCatalog_id();
												String catalog_name= catalogList.get(i).getCatalog_name();
											
											%>
												<option id=<%=catalog_id%>  value=<%=catalog_name %>> <%=catalog_name %> </option>
												<%} %>
											</select>
											<br />
										</p>
									</form>
								</div>
							</div>
						</div>
						<div class="title">
							Users
						</div>
						<div class="modules_right">
							<div class="module search">
								<form action="">
									<p><input type="text" value="Search..." name="user_search" /></p>
								</form>
							</div>
						</div>
					</div>
					<div id="desc">
						<div class="body">
						<form name="myform" method="post" id="myform" action="">
							<div class="col w10 last">
								<div class="content">
								<table>
										<tr>
										<th class="checkbox"><input name='chkAll' type='checkbox' id='chkAll' onclick='CheckAll(this.form)' value='checkbox'></th>
											<th>类型</th>
											<th>名称</th>
											<th>型号</th>
											<th>数量</th>
											<th>最小数量</th>
											<th>位置</th>
											<th>资产编号</th>
											<th>s/n编号</th>
										</tr>
										<%
										GoodsCtrl gc= new GoodsCtrl();
										ArrayList<Goods> goodslist = gc.getGoods();
										if(goodslist==null)
										{
											goodslist = new ArrayList<Goods>();
										}
										int account = goodslist.size();
										for(int i =0;i<account;i++)
										{
											int catalog_id= goodslist.get(i).getCatalog_id();
											String catalog_name=gc.findByCatalogId(catalog_id);
											String goods_name=goodslist.get(i).getGoods_name();
											String goods_type=goodslist.get(i).getGood_type();
											int amount = goodslist.get(i).getAmount();
											int min_amount = goodslist.get(i).getMin_amount();
											int goods_id =goodslist.get(i).getGoods_id();
											int property_id = goodslist.get(i).getProperty_id();
											String position = goodslist.get(i).getPosition();
											String sn_id = goodslist.get(i).getSn_id();
											boolean order_flag = goodslist.get(i).isOrder_flag();
											//System.out.println(goods_name);
											
										
										%>
										<tr id=<%=goods_id%>>
										<td class="checkbox"><input type="checkbox" name="id" onclick='unselectall()' value=<%=goods_id %> /><%-- <input type="text" name="number" id="number" class="text w_2" value=<%=number%>/> --%></td>
											<td><%=catalog_name %></td>
											<td><a href="editGood.jsp?goods_id=<%=goods_id%>" ><%=goods_name %></a></td>
											<td><%=goods_type %></td>
											<td><%=amount %></td>
											<td><%=min_amount %></td>
											<td>
											<%=position %>
											</td>
											<td>
											<%=property_id %>
											</td>
											<td>
											<%=sn_id %>
											</td>
										</tr>
									<%} %>	
										
									</table>
									<%
                                    /*  String arr[]=  request.getParameterValues("id");//.getAttributeNames("id");//.getParameterValues("id");//这时接收到的就是一个数组了
                                     for(String check:arr){
                                    	 if(check!=null&&!"".equals(check)){
                                    		System.out.println(check+"被选中！"); 
                                    	 }
                                     } */
                                     /* for(int i=0;i<arr.length;i++){
                                      out.println(arr[i]);
                                      } */
                                     %>	
						<a href="" class="button" onclick="CheckSingle()" id="create-user">
						<small class="icon check"></small>
						<span>领用</span></a>
										
						</div>
						<div class="clear"></div>
							</div>
							</form>
							<div class="clear"></div>
						</div>
						
						<div class="clear"></div>
						<div id="body_footer">
							<div id="bottom_left"><div id="bottom_right"></div></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div id="footer">
			<p class="last"><a href=""></a></p>
		</div>
		
		
</body>
</html>